package mo.leetcode_top;


public class L1736 {

    public String maximumTime(String time) {
        char[] hour = new char[]{time.charAt(0), time.charAt(1)};
        char[] minute = new char[]{time.charAt(3), time.charAt(4)};

        if (hour[0] == '?') {
            if (hour[1] == '?') {
                hour[0] = '2';
                hour[1] = '3';
            } else {
                if (hour[1] >= '4') {
                    hour[0] = '1';
                } else {
                    hour[0] = '2';
                }
            }
        } else if (hour[1] == '?') {
           if (hour[0] != '2') {
               hour[1] = '9';
           } else {
               hour[1] = '3';
           }
        }

        if (minute[0] == '?') {
            minute[0] = '5';
        }
        if (minute[1] == '?') {
            minute[1] = '9';
        }
        StringBuilder builder = new StringBuilder();
        return builder.append(hour[0]).append(hour[1]).append(":").append(minute[0]).append(minute[1]).toString();
    }

    public static void main(String[] args) {
        L1736 test = new L1736();
        System.out.println(test.maximumTime("??:??"));
    }

}
